Skip to content

feat: make ALLOWED_HTTP_HOSTS configurable via env var#3

Merged
jeremyeder merged 1 commit intomainfrom
feat/allowed-http-hosts-env
Mar 20, 2026
Merged

feat: make ALLOWED_HTTP_HOSTS configurable via env var#3
jeremyeder merged 1 commit intomainfrom
feat/allowed-http-hosts-env

Conversation

@jeremyeder
Copy link
Copy Markdown
Contributor

Summary

  • Add ALLOWED_HTTP_HOSTS env var support in mcp_server.py (comma-separated hostnames appended to the default allow list)
  • deploy.sh auto-injects the OpenShift route hostname into ALLOWED_HTTP_HOSTS on apply
  • Fixes 421 Misdirected Request when accessing /mcp via the OpenShift route

Test plan

  • scripts/test.sh passes (11/11)
  • /health returns {"status": "ok"}
  • /mcp returns successful MCP initialize response via route

🤖 Generated with Claude Code

Add support for ALLOWED_HTTP_HOSTS environment variable (comma-separated)
to allow external hostnames through DNS rebinding protection. deploy.sh
now auto-injects the OpenShift route hostname on apply.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jeremyeder jeremyeder merged commit 78c396f into main Mar 20, 2026
3 checks passed
@jeremyeder jeremyeder deleted the feat/allowed-http-hosts-env branch March 20, 2026 19:54
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 20, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a7da977b-e37d-4974-9ad9-e1a4d1317ece

📥 Commits

Reviewing files that changed from the base of the PR and between b99ff5c and 09e3b1f.

📒 Files selected for processing (2)
  • deploy/deploy.sh
  • mcp_server.py

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting


Walkthrough

The changes implement dynamic HTTP hosts allowlist configuration for OpenShift deployments. The deploy script extracts the Route hostname and sets it as an environment variable, which the mcp_server application reads at startup to extend its allowed hosts configuration for DNS rebinding protection.

Changes

Cohort / File(s) Summary
Deployment Script
deploy/deploy.sh
Added conditional logic to fetch OpenShift Route hostname and set ALLOWED_HTTP_HOSTS environment variable on the gps-mcp-server deployment during cmd_apply when OVERLAY is openshift.
Application Server
mcp_server.py
Added environment variable reading to extend HTTP transport ALLOWED_HTTP_HOSTS list by parsing comma-separated values from ALLOWED_HTTP_HOSTS env var and appending non-empty entries to existing defaults used in DNS rebinding protection.

Sequence Diagram

sequenceDiagram
    participant Deploy as Deploy Script
    participant OpenShift as OpenShift API
    participant Kubectl as kubectl/oc
    participant Deployment as Deployment
    participant App as mcp_server

    Deploy->>OpenShift: Query Route hostname for gps-mcp-server
    OpenShift-->>Deploy: Return .spec.host
    Deploy->>Kubectl: Set ALLOWED_HTTP_HOSTS env var on deployment
    Kubectl->>Deployment: Update environment
    Deployment->>App: Start application with env var
    App->>App: Read ALLOWED_HTTP_HOSTS from environment
    App->>App: Parse comma-separated values
    App->>App: Append to existing allowed_hosts list
    App->>App: Configure DNS rebinding protection
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/allowed-http-hosts-env

Comment @coderabbitai help to get the list of available commands and usage tips.

jeremyeder added a commit that referenced this pull request Mar 23, 2026
Add support for ALLOWED_HTTP_HOSTS environment variable (comma-separated)
to allow external hostnames through DNS rebinding protection. deploy.sh
now auto-injects the OpenShift route hostname on apply.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant